package com.xinli.business.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xinli.business.domain.TQuestionReply;
import com.xinli.business.domain.TQuestionReplyComment;
import com.xinli.business.mapper.TQuestionReplyMapper;
import com.xinli.business.service.ITQuestionReplyCommentService;
import com.xinli.business.service.ITQuestionReplyService;
import com.xinli.business.service.ITZxsFollowService;
import com.xinli.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 问题回复Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-24
 */
@Service
public class TQuestionReplyServiceImpl extends ServiceImpl<TQuestionReplyMapper, TQuestionReply>  implements ITQuestionReplyService
{
    @Autowired
    private TQuestionReplyMapper tQuestionReplyMapper;

    /**
     * 查询问题回复
     *
     * @param id 问题回复主键
     * @return 问题回复
     */
    @Override
    public TQuestionReply selectTQuestionReplyById(String id)
    {
        return tQuestionReplyMapper.selectTQuestionReplyById(id);
    }

    /**
     * 查询问题回复列表
     *
     * @param tQuestionReply 问题回复
     * @return 问题回复
     */
    @Override
    public List<TQuestionReply> selectTQuestionReplyList(TQuestionReply tQuestionReply)
    {
        return tQuestionReplyMapper.selectTQuestionReplyList(tQuestionReply);
    }

    /**
     * 新增问题回复
     *
     * @param tQuestionReply 问题回复
     * @return 结果
     */
    @Override
    public int insertTQuestionReply(TQuestionReply tQuestionReply)
    {
                tQuestionReply.setCreateTime(DateUtils.getNowDate());
            return tQuestionReplyMapper.insertTQuestionReply(tQuestionReply);
    }

    /**
     * 修改问题回复
     *
     * @param tQuestionReply 问题回复
     * @return 结果
     */
    @Override
    public int updateTQuestionReply(TQuestionReply tQuestionReply)
    {
                tQuestionReply.setUpdateTime(DateUtils.getNowDate());
        return tQuestionReplyMapper.updateTQuestionReply(tQuestionReply);
    }

    /**
     * 批量删除问题回复
     *
     * @param ids 需要删除的问题回复主键
     * @return 结果
     */
    @Override
    public int deleteTQuestionReplyByIds(String[] ids)
    {
        return tQuestionReplyMapper.deleteTQuestionReplyByIds(ids);
    }

    /**
     * 删除问题回复信息
     *
     * @param id 问题回复主键
     * @return 结果
     */
    @Override
    public int deleteTQuestionReplyById(String id)
    {
        return tQuestionReplyMapper.deleteTQuestionReplyById(id);
    }


    private  ITZxsFollowService followService;

    @Autowired
    private ITQuestionReplyCommentService replyCommentService;

    @Override
    public void setQuestionReplyCount(TQuestionReply  reply)
    {
        QueryWrapper<TQuestionReplyComment> wrapper = new QueryWrapper<>();
        wrapper.eq("business_id",reply.getId());
        long count = replyCommentService.count(wrapper);
        reply.setPlCount(count);
    }



}
